import { defineStore } from 'pinia'
import getAnswers from '@/request/getAnswers'
import getSurvey from '@/request/getSpecifySurvey'

export default defineStore('statAnswerData', {
  state: () => ({
    answers: [],
    survey: {},
  }),
  actions: {
    async getData() {
      await this.updateAnswers()
      await this.updateSurvey()
      return {
        answers: this.answers,
        survey: this.survey,
      }
    },
    async updateAnswers() {
      this.answers = await getAnswers()
      return
    },
    async updateSurvey() {
      this.survey = await getSurvey()
      return
    },
  },
})
